package com.tf.six.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tf.six.entity.UserCollection;
import com.tf.six.mapper.UserCollectionMapper;
import com.tf.six.service.UserCollectionService;
import org.springframework.stereotype.Service;

@Service
public class UserCollectionServiceImpl extends ServiceImpl<UserCollectionMapper, UserCollection> implements UserCollectionService {
    @Override
    public boolean addCollection(Integer userId, Integer itemId) {
        UserCollection collection = new UserCollection();
        collection.setUserId(userId);
        collection.setItemId(itemId);
        return this.save(collection);
    }

    @Override
    public boolean removeCollection(Integer userId, Integer itemId) {
        return this.lambdaUpdate().eq(UserCollection::getUserId, userId).eq(UserCollection::getItemId, itemId).remove();
    }
}
